/*
 * @Author: 刘晓伟 1748805421@qq.com
 * @Date: 2024-04-09 09:30:35
 * @LastEditors: 刘晓伟 1748805421@qq.com
 * @LastEditTime: 2024-07-19 14:56:24
 * @Description: 
 * Copyright (c) 2024-present HBIS Digital Technology Co.,Ltd. All rights reserved. 
 */
import { default as request, cloud } from '@/framework/utils/request'
import { DictListType, DictIdType, DictFormData, DictIdsType, DictImportType } from './types'
import { ResultData, ResultDataList } from '@/framework/api/common';
import { DictEnumImportType } from './dict-enum-manage/types'
// 获取字典管理列表
export function dictManagePage(params: Partial<DictListType>): Promise<ResultDataList<DictListType>> {
    return request({
        url: cloud.dqBasic + '/dictManage/page',
        method: 'get',
        params
    })
}
// 获取字典管理详情
export function dictManageDetail(params: DictIdType): Promise<ResultData<DictListType>> {
    return request({
        url: cloud.dqBasic + '/dictManage/detail',
        method: 'get',
        params
    })
}
// 新增字典管理
export function dictManageAdd(data: DictFormData): Promise<ResultData<null>> {
    return request({
        url: cloud.dqBasic + '/dictManage/add',
        method: 'post',
        data
    })
}
// 修改字典管理
export function dictManageEdit(data: DictFormData | DictIdType): Promise<ResultData<null>> {
    return request({
        url: cloud.dqBasic + '/dictManage/edit',
        method: 'post',
        data
    })
}
// 删除字典管理
export function dictManageDelete(data: DictIdType): Promise<ResultData<null>> {
    return request({
        url: cloud.dqBasic + '/dictManage/delete',
        method: 'post',
        data
    })
}
//导出选中字典数据
export function dictManageExport(data: DictIdsType): Promise<ResultData<BlobPart>> {
    return request({
        url: cloud.dqBasic + '/dictManage/export',
        method: 'post',
        data,
        responseType: 'arraybuffer'
    })
}
// 导出全部数据
export function dictManageExportAll(params: DictIdsType): Promise<ResultData<BlobPart>> {
    return request({
        url: cloud.dqBasic + '/dictManage/exportAll',
        method: 'get',
        params,
        responseType: 'arraybuffer'
    })
}
// 导入下载模板
export function dictImportTemplate(params: DictIdType): Promise<ResultData<Blob>> {
    return request({
        url: cloud.dqBasic + '/dictManage/import/template',
        method: 'get',
        params,
        responseType: 'arraybuffer'
    })
}
// 导入数据
export function dictManageImport(data: DictEnumImportType): Promise<ResultData<DictImportType>> {
    return request({
        url: cloud.dqBasic + '/dictManage/import',
        method: 'post',
        data: data.formData,
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}